package com.xxx.clickhousedemo.controller;

import com.xxx.clickhousedemo.pojo.bean.ResponseDTO;
import com.xxx.clickhousedemo.pojo.entity.ClickUser;
import com.xxx.clickhousedemo.service.ChickHouserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
public class TestController {

    @Resource
    private ChickHouserService chickHouserService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ResponseDTO list() {
        List<ClickUser> list = chickHouserService.getList();
        return ResponseDTO.builtSuccess(list);
    }

    @RequestMapping(value = "/insert", method = RequestMethod.GET)
    public ResponseDTO insert() {
        ClickUser clickUser = new ClickUser();
        clickUser.setUserId(2);
        clickUser.setAppId("b");
        clickUser.setRegTime(new Date());
        clickUser.setVersion("1");
        List<ClickUser> list = chickHouserService.insert(clickUser);
        return ResponseDTO.builtSuccess(list);
    }

}
